﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PicSolve;

namespace PicTests
{
    [TestClass]
    public class PLineBuilderTest
    {
        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException), "nbBox > length")]
        public void FilledOnLeftTest()
        {
            PLine p = PLineBuilder.FilledOnLeft(6, 10);
            Assert.IsTrue(p.ToString().Equals("111111----"));

            p = PLineBuilder.FilledOnLeft(11, 10);
            //Assert.
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException), "nbBox > length")]
        public void FilledOnRightTest()
        {
            PLine p = PLineBuilder.FilledOnRight(6, 10);
            Assert.IsTrue(p.ToString().Equals("----111111"));

            p = PLineBuilder.FilledOnRight(11, 10);
        }

        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException), "decal + nbBox > lineLength")]
        public void FilledInsideTest()
        {
            PLine p = PLineBuilder.FilledInside(2, 5, 10);
            Assert.IsTrue(p.ToString().Equals("--11111---"));

            p = PLineBuilder.FilledInside(3, 8, 10);
        }


        [TestMethod]
        [ExpectedException(typeof(InvalidOperationException), "Impossible de créer la ligne, la taille totale des indices ne correspond pas à la taille de la ligne")]
        public void FilledTest()
        {
            PLine p = PLineBuilder.FilledWithSimplePattern(new int[3] { 6, 3, 4 }, lineLength: 10);

            p = PLineBuilder.FilledWithSimplePattern(new int[3] { 6, 3, 4 }, lineLength: 15);
            Assert.IsTrue(p.ToString().Equals("111111011101111"));
        }

        [TestMethod]
        public void WithPatternInsideTest()
        {
            var p = PLineBuilder.WithSimplePatternInside(2, new int[3] { 2, 1, 3 }, lineLength: 10);
            Assert.IsTrue(p.ToString().Equals("--11010111"));

            p = PLineBuilder.WithSimplePatternInside(2, new int[3] { 2, 1, 3 }, lineLength: 14);
            Assert.IsTrue(p.ToString().Equals("--11010111----"));
        }
    }
}
